package ctrip;

import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int numberCount;
		int target;
		int[] numbers;
		while(scanner.hasNext()){
			target = scanner.nextInt();
			numberCount = scanner.nextInt();
			numbers = new int[numberCount];
			for (int i = 0; i < numberCount; i++) {
				numbers[i] = scanner.nextInt();
			}
			realFind(numbers, target,0, numberCount - 1);
		}
		scanner.close();
	}
	
	//如果存在则返回出现的位置
	public static int realFind(int[] A, int target, int left, int right) {
		
		int index = -1;
		if (left >= A.length || left > right) {
			System.out.println(-1 - left);
			return -1;
		}
		int middle = left + (right - left) / 2;
		if (A[middle] == target) {
			// 注意这里要返回的是第一次出现的次数
//			for (int i = middle - 1; i >= 0; i--) {
//				if (A[i] == target) {
//					middle = i;
//				} else {
//					return middle;
//				}
//			}
			System.out.println(middle);
			return middle;
		} else if (A[middle] < target) {
			index = realFind(A, target, middle + 1, right);
		} else {
			index = realFind(A, target, left, middle - 1);
		}
		return index;
	}
}
